<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html lang="en">
<head>
    <title>扫码支付</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta name="viewport"  content="width=device-width,initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
    <link rel="stylesheet" type="text/css" href="../resources/styles/pinus.css">
        <link rel="stylesheet" href="../resources/weui/style/weui.css"/>
<!--         
    <meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
    <meta http-equiv="Pragma" content="no-cache" />
    <meta http-equiv="Expires" content="0" />
     -->
<style>
	.logo {
	  width: 86px;
	  height: 20px;
	  margin: auto;
	  display: block;
	  background: url(../resources/img/logo.png) no-repeat top center;
	  background-size: 86px 18px;
	  padding-top: 10px
	}
	table,th,td {
		border: 1px solid blue;
	}
	html, body{ margin:0; height:99%; background-color:  #F5F5F5}
</style>
</head>

<body>

<section class="block">
  <div style="" >
	<img src="../resources/img/zzzf.gif"	width="100%" height="auto">
  </div>
    <div class="ch" >
        <span  id="status" ><span class='up' >正在支付 请稍后</span></span>
    </div>
    <div class="weui-footer weui-footer_fixed-bottom">
        <p class="weui-footer__text" style="color: #000;margin-top: 5px;">
            <img height="10px" src="../resources/img/logo.png"/>
  		   <div style="width: 100%;text-align: center;color: 	#A9A9A9;font-size: 12px ;font-family: FangSong">北京路盟科技有限公司</div>
        </p>
    </div>
    
<%-- <div id="aliPayUrl">${data.aliPayUrl}</div> --%>
</section>
<script src="../resources/script/pingpp.js" type="text/javascript"></script>
<script type="text/javascript" src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
<script src="https://gw.alipayobjects.com/as/g/h5-lib/alipayjsapi/3.1.0/alipayjsapi.min.js"></script>
<script type="text/javascript">
window.onload=function(){
	if('${data.isok}'=='1'){
		 document.getElementById("status").innerHTML=" <span class='up' >该订单已支付</span>";
		return;
	}
	
	if('${data.mhtOrderAmtStr}'){
		//支付宝支付
		if('${data.channel}' == '12'){
			var options = { "tradeNO":'${data.tradeNO}' };
			AlipayJSBridge.call('tradePay', options ,function(result){
				if(result.resultCode == '9000'){
					
				}
				if(result.resultCode == '6001'){
					// alert("支付已取消");
				}
				AlipayJSBridge.call('closeWebview');
			});
		}
		//微信支付
		if('${data.channel}' == '13'){
			var payInfo = '${data.payInfo}';
			var obj = eval('(' + payInfo + ')');
			if (typeof WeixinJSBridge == "undefined"){
			   if( document.addEventListener ){
			       document.addEventListener('WeixinJSBridgeReady', onBridgeReady, false);
			   }else if (document.attachEvent){
			       document.attachEvent('WeixinJSBridgeReady', onBridgeReady); 
			       document.attachEvent('onWeixinJSBridgeReady', onBridgeReady);
			   }
			} else {
				onBridgeReady();
			}
			
			function onBridgeReady(){
			   WeixinJSBridge.invoke(
			       'getBrandWCPayRequest', {
			           "appId":obj.appId,     //公众号名称，由商户传入     
			           "timeStamp":obj.timeStamp,         //时间戳，自1970年以来的秒数     
			           "nonceStr":obj.nonceStr, //随机串     
			           "package":obj.packageInfo,     
			           "signType":obj.signType,         //微信签名方式：     
			           "paySign":obj.paySign //微信签名 
			       },
			       function(res){     
			           if(res.err_msg == "get_brand_wcpay_request:ok" ) {
			        	 // alert("支付成功");
			           }else if (res.err_msg == "get_brand_wcpay_request:cancel")  {
			        	 // alert("支付已取消");
						}else{
			             // alert("支付失败,请重试");
			            }
			           WeixinJSBridge.call('closeWindow');
			       }
			   ); 
			}
		}
	}else{
	    document.getElementById("status").innerHTML=" <span class='up' >请使用微信或者支付宝打开进行扫码支付</span>";
	}
}
</script>
</body>
</html>
